Skip to content

Remove test console warnings and add CI enforcement#7820

Open
Copilot wants to merge 16 commits into
mainfrom
copilot/remove-act-warnings-in-tests
Open

Remove test console warnings and add CI enforcement#7820
Copilot wants to merge 16 commits into
mainfrom
copilot/remove-act-warnings-in-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Changelog

New

  • Added a shared @primer/vitest-config workspace package for the common Vitest console-enforcement setup.
  • Added package-local config/vitest/setup.ts entrypoints so each package can consume the shared Vitest setup without relying on a top-level setup script path.

Changed

  • Updated AnchoredOverlay to re-sync CSS anchor-positioning state when an external anchorRef DOM node is replaced while the overlay remains open.
  • Preserved existing internal renderAnchor behavior while fixing the React 19 external-anchor remount case that caused anchor-name and position-anchor to fall out of sync.
  • Added an inline code comment documenting the React 19-specific external anchor replacement behavior.
  • Updated package Vitest configs to use the new shared setup package through package-local TypeScript setup entrypoints.
  • Added the minimum TypeScript project includes needed for lint/type-aware parsing of the renamed setup files.
  • Resolved merge conflicts in the node Vitest configs by keeping both the setup.ts entrypoints from this PR and the upstream detectAsyncLeaks: true updates.
  • Scoped @primer/doc-gen's declaration build back to src/**/* so the new config/vitest/setup.ts entrypoint remains available for tooling without being pulled into the published build and breaking CI with TS6059.

Removed

  • Removed the top-level shared Vitest setup script at script/vitest/setup.ts.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

  • Analyzed the failing GitHub Actions test (react-19) job logs for run 25577112553, job 75087602292.
  • Reproduced the original failure locally against packages/react/src/ActionMenu/ActionMenu.test.tsx.
  • Verified the AnchoredOverlay fix with:
    • npx vitest --config vitest.config.browser.mts run src/AnchoredOverlay/AnchoredOverlay.test.tsx
    • npx vitest --config vitest.config.browser.mts run src/ActionMenu/ActionMenu.test.tsx
  • Verified the shared Vitest setup refactor with:
    • npm run lint -- --no-cache
    • npm run type-check
    • cd packages/styled-react && npx vitest --run src/__tests__/exports.test.ts
    • cd packages/react && npx vitest --config vitest.config.browser.mts run src/AnchoredOverlay/AnchoredOverlay.test.tsx
  • Verified the follow-up setup.ts rename and TS config updates with:
    • cd packages/react && npx vitest --config vitest.config.mts run src/__tests__/exports.test.ts
    • cd packages/styled-react && npx vitest --config vitest.config.ts run src/__tests__/exports.test.ts
    • cd packages/doc-gen && npx vitest --config vitest.config.mts run --passWithNoTests
    • cd packages/postcss-preset-primer && npx vitest --config vitest.config.ts run --passWithNoTests
    • npm run lint -- --no-cache packages/vitest-config/setup.ts packages/react/config/vitest/setup.ts packages/styled-react/config/vitest/setup.ts packages/doc-gen/config/vitest/setup.ts packages/postcss-preset-primer/config/vitest/setup.ts packages/react/vitest.config.mts packages/react/vitest.config.browser.mts packages/styled-react/vitest.config.ts packages/styled-react/vitest.config.browser.ts packages/doc-gen/vitest.config.mts packages/postcss-preset-primer/vitest.config.ts
    • npx tsc -p packages/vitest-config/tsconfig.json --noEmit
    • npx tsc -p packages/doc-gen/tsconfig.json --noEmit
    • npx tsc -p packages/postcss-preset-primer/tsconfig.json --noEmit
  • Resolved the PR merge conflicts by merging origin/main and re-validating the conflicted Vitest config files with:
    • npm run lint -- --no-cache packages/react/vitest.config.mts packages/styled-react/vitest.config.ts packages/doc-gen/vitest.config.mts packages/postcss-preset-primer/vitest.config.ts
    • cd packages/react && npx vitest --config vitest.config.mts run src/__tests__/exports.test.ts
    • cd packages/doc-gen && npx vitest --config vitest.config.mts run
  • Analyzed the later failing GitHub Actions CI logs for run 25677748363 and traced the regression to the @primer/doc-gen build.
  • Verified the CI follow-up fix with:
    • cd packages/doc-gen && npm run build
    • npm run build
    • npm run type-check
    • cd packages/styled-react && npx vitest --config vitest.config.ts run src/__tests__/exports.test.ts
  • Ran secret scanning and final automated review / CodeQL validation.

Merge checklist

Copilot AI and others added 4 commits May 7, 2026 19:34
Agent-Logs-Url: https://github.com/primer/react/sessions/6f872a32-6ca6-4638-b31e-81b5134c5538

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/6f872a32-6ca6-4638-b31e-81b5134c5538

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/6f872a32-6ca6-4638-b31e-81b5134c5538

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/6f872a32-6ca6-4638-b31e-81b5134c5538

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

⚠️ No Changeset found

Latest commit: 618e2ea

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@github-actions github-actions Bot temporarily deployed to storybook-preview-7820 May 7, 2026 20:44 Inactive
@joshblack joshblack added the skip changeset This change does not need a changelog label May 8, 2026
@joshblack
Copy link
Copy Markdown
Member

@copilot fix CI, it is currently broken. Don't submit changes for review until CI is green

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 8, 2026

@copilot fix CI, it is currently broken. Don't submit changes for review until CI is green

Fixed in b0e2fcd. Local validation is green (CI=true npm run test, npm run lint -- --no-cache, npm run type-check, npm run build, npm run lint:css, npm run format:diff -- --cache=false). The new GitHub Actions runs are currently action_required with no jobs, so they need approval before CI can turn green; I have not submitted the PR for review.

Copilot AI and others added 2 commits May 8, 2026 20:41
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Copilot AI changed the title Remove test console warnings and add CI enforcement Fix react-19 external anchor replacement in AnchoredOverlay May 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7820 May 8, 2026 21:03 Inactive
Copy link
Copy Markdown
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot create a shared vitest config package that can be used instead of a common script at the top-level

@github-actions github-actions Bot requested a deployment to storybook-preview-7820 May 11, 2026 15:31 Abandoned
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot fix failing CI

Addressed in 228e350. The CI failure was the @primer/doc-gen build pulling config/vitest/setup.ts into the declaration build; scoping tsconfig.build.json back to src/**/* fixes that. Local validation is green with cd packages/doc-gen && npm run build, npm run build, npm run type-check, and cd packages/styled-react && npx vitest --config vitest.config.ts run src/__tests__/exports.test.ts. The new GitHub Actions runs are currently action_required, so they need approval before CI can re-run.

Copilot AI changed the title Fix react-19 external anchor replacement in AnchoredOverlay and share Vitest setup Fix react-19 external anchor replacement in AnchoredOverlay, share Vitest setup, and restore doc-gen CI build May 11, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7820 May 11, 2026 15:58 Inactive
@joshblack joshblack changed the title Fix react-19 external anchor replacement in AnchoredOverlay, share Vitest setup, and restore doc-gen CI build Remove test console warnings and add CI enforcement May 12, 2026
@joshblack joshblack marked this pull request as ready for review May 12, 2026 17:00
@joshblack joshblack requested a review from a team as a code owner May 12, 2026 17:00
Copilot AI review requested due to automatic review settings May 12, 2026 17:00
Comment thread packages/vitest-config/setup.ts Outdated
Comment on lines +5 to +23
allowMessage: message => {
return [
/Found duplicate ".+" slot\. Only the first will be rendered\./,
/A choice group must be labelled using a `CheckboxOrRadioGroup\.Label` child/,
/A radio input must have a `name` attribute\./,
/The input field with the id .+ MUST have a FormControl\.Label child\./,
/React does not recognize the `leadingVisual` prop on a DOM element\./,
/The <Details> component must have a <summary> child component\./,
/The above error occurred in the <.+> component:/,
/The `Tooltip` component expects a single React element that contains interactive content\./,
/Use the `aria-label` or `aria-labelledby` prop to provide an accessible label/,
/Uncaught Invariant Violation:/,
/validateDOMNesting\(\.\.\.\): <button> cannot appear as a descendant of <button>\./,
/validateDOMNesting\(\.\.\.\): <td> cannot appear as a child of <div>\./,
].some(pattern => pattern.test(message))
},
silenceMessage: message => {
return /Warning: An update to AnchoredOverlay inside a test was not wrapped in act/.test(message)
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot instead of allowing these messages, update the corresponding test to make assertion on these logs being emitted or fix the underlying test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 4434a49. I removed the shared allowlist, updated the affected tests to explicitly assert the expected warnings/errors (or render valid inputs), and fixed UnderlineNav overflow prop forwarding so leadingVisual no longer leaks to the DOM. Validated with targeted CI=true browser Vitest runs for the touched suites plus lint on the changed files.

@joshblack joshblack requested review from a team and joshblack May 12, 2026 17:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes Vitest console-enforcement across workspaces (to prevent CI-only console noise), updates multiple test suites to eliminate warnings under React 19/browser Vitest, and adjusts AnchoredOverlay to re-sync CSS anchor-positioning when an externally managed anchor DOM node is replaced while the overlay remains open.

Changes:

  • Introduces a shared @primer/vitest-config package for CI console enforcement and wires it into each workspace via package-local config/vitest/setup.ts.
  • Fixes AnchoredOverlay CSS anchor-positioning behavior for React 19 external-anchor replacement, and updates related tests.
  • Cleans up various component/test behaviors that triggered console warnings (focus/act timing, ResizeObserver mocking, deprecated nested-button render, ref cleanup semantics).
Show a summary per file
File Description
packages/vitest-config/tsconfig.json Adds TS config for the shared vitest setup entrypoint.
packages/vitest-config/setup.ts Implements CI-only vitest-fail-on-console enforcement with allow/silence patterns.
packages/vitest-config/package.json Defines the private workspace package and exports ./setup.
packages/styled-react/vitest.config.ts Adds shared setup file for node tests.
packages/styled-react/vitest.config.browser.ts Adds shared setup for browser tests and defines process.env.CI for browser execution.
packages/styled-react/src/tests/primer-react-deprecated.browser.test.tsx Avoids nested-button DOM nesting warning by changing the rendered element.
packages/styled-react/config/vitest/setup.ts Package-local entrypoint importing the shared Vitest setup.
packages/react/vitest.config.mts Adds shared setup file for node tests.
packages/react/vitest.config.browser.mts Adds shared setup file for browser tests (before browser-specific setup).
packages/react/src/SelectPanel/SelectPanel.test.tsx Refactors focus-management selection helper usage in tests.
packages/react/src/PageLayout/usePaneWidth.test.ts Wraps resize dispatches in act to avoid warnings and improve timing correctness.
packages/react/src/live-region/Announce.tsx Switches previous announcement tracking from state to ref to avoid extra renders.
packages/react/src/LabelGroup/LabelGroup.test.tsx Adds ResizeObserver mock + extra focus assertions for overlay close behavior.
packages/react/src/hooks/useMergedRefs.ts Adds React-version gating for callback-ref cleanup behavior (React 19 vs 18).
packages/react/src/hooks/tests/useMergedRefs.test.tsx Updates tests to assert different ref-cleanup semantics across React versions.
packages/react/src/experimental/Tabs/Tabs.test.tsx Aligns interaction simulation with component behavior (onMouseDown selection).
packages/react/src/Dialog/Dialog.tsx Removes footer layout state and relies on attribute updates for layout selection.
packages/react/src/deprecated/ActionList/Group.tsx Stops forwarding groupId onto the DOM by stripping it from props.
packages/react/src/DataTable/tests/Table.test.tsx Updates implementsClassName usage to mount Table.Cell within proper table structure.
packages/react/src/ConfirmationDialog/ConfirmationDialog.test.tsx Adds layout-wait helper and updates interactions to use userEvent.
packages/react/src/CircleBadge/CircleBadge.tsx Stops leaking non-DOM props as DOM attributes by destructuring and narrowing style inputs.
packages/react/src/CircleBadge/snapshots/CircleBadge.test.tsx.snap Updates snapshots to reflect removed DOM attributes (size/variant).
packages/react/src/Breadcrumbs/Breadcrumbs.tsx Removes a tooltip direction override from the overflow menu IconButton.
packages/react/src/Breadcrumbs/tests/Breadcrumbs.test.tsx Wraps ResizeObserver and focus interactions in act/waitFor for stability.
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Tracks external anchor replacement (React 19) and re-applies CSS anchor-positioning state.
packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx Waits for async style application when anchors are replaced.
packages/react/src/ActionMenu/ActionMenu.test.tsx Removes unnecessary act wrappers and waits for anchor-name style re-application.
packages/react/src/ActionBar/ActionBar.test.tsx Uses waitFor/effect flushing helpers to avoid timing-related warnings.
packages/react/config/vitest/setup.ts Package-local entrypoint importing the shared Vitest setup.
packages/postcss-preset-primer/vitest.config.ts Adds shared setup file for node tests.
packages/postcss-preset-primer/tsconfig.json Includes config/**/*.ts for type-aware linting/parsing of the new setup entrypoint.
packages/postcss-preset-primer/config/vitest/setup.ts Package-local entrypoint importing the shared Vitest setup.
packages/doc-gen/vitest.config.mts Adds shared setup file for node tests.
packages/doc-gen/tsconfig.json Includes config/**/*.ts for type-aware linting/parsing of the new setup entrypoint.
packages/doc-gen/tsconfig.build.json Restricts declaration build include to src/**/* to avoid build rootDir issues.
packages/doc-gen/config/vitest/setup.ts Package-local entrypoint importing the shared Vitest setup.
package.json Adds vitest-fail-on-console dependency at the repo root.
package-lock.json Locks vitest-fail-on-console and links the new @primer/vitest-config workspace.

Copilot's findings

  • Files reviewed: 37/38 changed files
  • Comments generated: 2

Comment on lines 356 to 401
// We temporarily force "wrap" the footer layout so that the browser can calculate the body height -
// when the footer is wrapping. This is instantaneous with what we set below (`dialogElement.setAttribute('data-footer-button-layout', newLayout)`).
dialogElement.setAttribute('data-footer-button-layout', 'wrap')
const bodyHeight = bodyWrapper.clientHeight

const newLayout = bodyHeight >= MIN_BODY_HEIGHT ? 'wrap' : 'scroll'
dialogElement.setAttribute('data-footer-button-layout', newLayout)

setFooterButtonLayout(newLayout)
}, [hasFooter])

useResizeObserver(updateFooterButtonLayout, backdropRef)

const positionDataAttributes =
typeof position === 'string'
? {'data-position-regular': position}
: Object.fromEntries(
Object.entries(position).map(([key, value]) => {
return [`data-position-${key}`, value]
}),
)

return (
<DialogContext.Provider value={DIALOG_CONTEXT_VALUE}>
<Portal>
<div
ref={backdropRef}
className={classes.Backdrop}
{...positionDataAttributes}
{...(align && {'data-align': align})}
onClick={onBackdropClick}
onMouseDown={(e: React.MouseEvent<HTMLDivElement>) => {
setLastMouseDownIsBackdrop(e.target === e.currentTarget)
}}
>
<div
ref={dialogRef}
role={role}
aria-labelledby={dialogLabelId}
aria-describedby={dialogDescriptionId}
aria-modal
{...positionDataAttributes}
{...(align && {'data-align': align})}
data-width={width}
data-height={height}
data-has-footer={hasFooter ? '' : undefined}
data-footer-button-layout={hasFooter ? footerButtonLayout : undefined}
data-footer-button-layout={hasFooter ? 'wrap' : undefined}
className={clsx(className, classes.Dialog)}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot defer to the original implementation and commit the result

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 618e2ea. I restored the original state-driven footer layout implementation in Dialog and re-ran the targeted Dialog browser tests plus lint.

Comment on lines +93 to +122
@@ -94,6 +110,16 @@ describe('LabelGroup', () => {
await waitFor(() => getByLabelText('Close'))

expect(document.activeElement).toBe(getByLabelText('Close'))

await user.click(getByLabelText('Close'))
await waitFor(() => {
expect(getByText('+2').closest('button')).toHaveFocus()
})
act(() => {
unmount()
})
consoleError.mockRestore()
restoreResizeObserver()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot commit the afterEach suggestion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 44d5a49. The LabelGroup overlay test now uses afterEach to always restore the console.error spy and ResizeObserver mock, and I re-ran lint plus the targeted browser Vitest file.

Copilot AI and others added 2 commits May 12, 2026 17:21
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants